<template>
  <div class="item">
    <div class="main">
      <div class="left">
        <div v-for="(item, index) in proClass" :key="index">{{ item }}</div>
      </div>
      <div class="right">
        <div v-for="(item, index) in foodList" :key="index">
          <p class="title">{{ item.name }}</p>
          <div
            v-for="food in foodList[index].foods"
            :key="food.id"
            class="flex"
          >
            <div class="numBtn">+</div>
            <div>
              <img :src="food.imgUrl" alt="" />
            </div>
            <div class="content">
              <h3>{{ food.name }}</h3>
              <p>商品评价:{{ food.rating }}%</p>
              <p>
                <span>￥{{ food.price.toFixed(2) }}</span>
              </p>
            </div>
          </div>
        </div>
      </div>
      <div class="bottom flex">
        <div class="link">
          <van-icon name="comment-o" size="24" />
          <p>联系商家</p>
        </div>
        <div class="flex content">
          <div class="icon">
            <van-icon name="shopping-cart-o" size="40" />
          </div>
          <div class="desc">
            <h3>￥0.00</h3>
            <p>另需配送费|支持自取</p>
          </div>
          <div class="price">￥20元起送</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { product } from "../apis/order";
export default {
  data() {
    return {
      proClass: [],
      foodList: [],
    };
  },
  created() {
    product().then((res) => {
      this.proClass = res.data.goodsList.map((item) => item.name);
      this.foodList = res.data.goodsList;
    });
  },
};
</script>

<style lang="less" scoped>
.item {
  flex: 1;
  overflow: hidden;
}
.main {
  display: flex;
  height: 100%;
  overflow: hidden;
  .left {
    width: 80px;
    height: 100%;
    background-color: #f5f5f5;
    overflow: scroll;
    div {
      font-size: 14px;
      line-height: 40px;
      text-align: center;
    }
  }
  .right {
    flex: 1;
    height: 100%;
    overflow: scroll;
    .title {
      font-size: 14px;
      padding-top: 10px;
      padding-left: 10px;
    }
    .flex {
      padding: 10px 14px 14px;
      position: relative;
      .numBtn {
        width: 20px;
        line-height: 20px;
        border-radius: 50%;
        text-align: center;
        background-color: #ffc300;
        position: absolute;
        bottom: 30px;
        right: 40px;
      }
      img {
        width: 100px;
        height: 100px;
        padding-right: 10px;
      }
      .content {
        h3 {
          font-size: 14px;
        }
        p {
          font-size: 14px;
          padding: 10px 0;
        }
        span {
          color: #ff5a2f;
        }
      }
    }
  }
  .bottom {
    position: fixed;
    height: 60px;
    width: 100%;
    border-radius: 60px;
    background-color: #222;
    bottom: 10px;
    color: #fff;
    justify-content: space-between;
    .link {
      padding: 10px 20px 10px 16px;
      width: 50px;
      font-size: 12px;
      text-align: center;
      border-right: 3px solid #fff;
    }
    .content {
      .icon {
        padding: 8px;
      }
      .desc {
        h3 {
          padding-top: 4px;
          font-size: 18px;
        }
        p {
          font-size: 14px;
        }
      }
      .price {
        padding: 20px 14px 10px 10px;
        font-size: 14px;
      }
    }
  }
}
</style>